﻿CREATE TABLE [dbo].[CAR](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[Plate] [varchar](50) NOT NULL,
	[Model] [varchar](50) NOT NULL,
	[OwnerId] [bigint] NOT NULL,
 CONSTRAINT [PK_CAR] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
));

go


CREATE TABLE [dbo].[PERSON](
	[Id] [bigint] IDENTITY(1,1) NOT NULL,
	[Name] [varchar](50) NOT NULL,
	[Surname] [varchar](50) NOT NULL,
	[DateOfBirth] [datetime] NOT NULL,
 CONSTRAINT [PK_PERSON] PRIMARY KEY CLUSTERED 
(
	[Id] ASC
));

go

CREATE PROC dbo.CAR_Load

	@ID		BIGINT
	
AS

	SELECT * FROM dbo.CAR
	WHERE Id = @ID;

go

CREATE PROC dbo.PERSON_Load

	@ID		BIGINT
	
AS

	SELECT * FROM dbo.PERSON
	WHERE Id = @ID;

go

CREATE PROC dbo.CAR_ListByOwner

	@ownerId		BIGINT
	
AS
	
	SELECT * FROM  dbo.CAR
	WHERE OwnerId = @ownerId;
	   
go

CREATE PROC dbo.PERSON_List

AS

	SELECT * FROM  dbo.PERSON;

go



